# -*- codeing = utf-8 -*-
from django.db.models import Q

from scripts import base
from user import models
from utils import encrypt


def add_user(username, password, phone, email):
    is_exist = models.UserInfo.objects.filter(Q(username=username) | Q(email=username) | Q(phone=username)).first()
    if not is_exist:
        password = encrypt.md5(password)
        models.UserInfo.objects.create(username=username, password=password, phone=phone, email=email)
    else:
        print('用户已存在')


if __name__ == '__main__':
    add_user('user', 'user123', '18822545525', 'test@test.com')
